package com.jt.redis.demos;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;

@Repository//注解用于描述数据层对列
public class SecondKillQueue {
    @Autowired
    private StringRedisTemplate redisTemplate;
    //执行入队操作
    public void enque(String msg){
        ListOperations<String, String> lo
                = redisTemplate.opsForList();
        lo.leftPush("killQueue", msg);
    }
    //执行出队操作
    public String deque(){
        ListOperations<String, String> lo
                = redisTemplate.opsForList();
        return lo.rightPop("killQueue");
    }

}
